package com.lovo.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.system.dto.UserRoleDto;
import com.lovo.system.mapper.UserRoleMapper;
import com.lovo.system.service.IUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRoleDto> implements IUserRoleService {

    @Autowired
    UserRoleMapper userRoleMapper;

    @Override
    public void insertUserRole(UserRoleDto userRoleDto) {
        userRoleMapper.insert(userRoleDto);
    }

    @Override
    public void deleteUserRole(int userId, int roleId) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("user_id",userId);
        qw.eq("role_id",roleId);
        userRoleMapper.delete(qw);
    }

    @Override
    public void deleteUserRoleByUser(int userId) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("user_id",userId);
        userRoleMapper.delete(qw);
    }

}
